package pl.edu.uj.tcs.blef.protocol;

/**
 * @uml.dependency   supplier="pl.edu.uj.tcs.blef.protocol.ParseFailedException"
 * @uml.dependency   supplier="pl.edu.uj.tcs.blef.protocol.Request"
 * @uml.dependency   supplier="pl.edu.uj.tcs.blef.protocol.BuildFailedException"
 * @author Maciej Bendkowski
 */
public interface RequestFactory {
		/**
		 * Trys to build a proper Request class using the given parameters.
		 * @param parameters Represents an table of parameters which are used for proper request building.
		 * @param handler The handler which should be used to build the request.
		 * @return A proper request class.
		 * @throws BuildFailedException If the build could not been successfully accomplished, f. e. due to  
		 * the lack of some parameters, wrong parameter type, etc.
		 */
		public abstract Request build(Object[] parameters, RequestHandler handler)	throws BuildFailedException ;

		/** 
		 * Trys to parse the given message and build a Request using this message.
		 * @param message The protocol message String which has to be parsed.
		 * @param handler The handler which should be used to build the request.
		 * @return A proper request class.
		 * @throws ParseFailedException If the given message could not been successfully recognized.
		 * @throws BuildFailedException If the build could not been successfully accomplished, f. e. due to  
		 * the lack of some parameters, wrong parameter type, etc.
		 */
		public abstract Request parse(String message, RequestHandler handler)	throws ParseFailedException, BuildFailedException ;
}
